<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	选择卡券modal，通过访问此页面选择获取指定卡券id
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$return['is_wechats']=array(
	'0'=>'系统卡券',
	'1'=>'微信卡券'
);
$return['types']=array(
	'1'=>'折扣券',
	'2'=>'代金券',
	'3'=>'兑换券',
	'4'=>'团购券',
	'5'=>'优惠券'
);
if($_RQ['op']='list'){
	//会员列表
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$return['params']=array();
	$params=array('uniacid'=>$_SESSION['uniacid']);
	
	//是否微信卡券
	if(isset($_RQ['is_wechat'])){
		$params['is_wechat']=intval($_RQ['is_wechat']);
		$return['params']['is_wechat']=$params['is_wechat'];
	}
	//卡券类型
	if(!empty($_RQ['type'])){
		$params['type']=intval($_RQ['type']);
		$return['type']=$params['type'];
	}
	//卡券名称
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby='id asc';
	$list=pdo_getslice('core_card',$params,array($pindex,$psize),$total,array('id','title','type','is_wechat'),'',$orderby);
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'卡券列表'),
		),
		'list'=>array('data'=>'list','list'=>array(
			array('name'=>'id','title'=>'卡券id','type'=>'string'),
			array('name'=>'title','title'=>'卡券名称','type'=>'string'),
			array('name'=>'types','title'=>'卡券类型','type'=>'radio','options'=>'types'),
			array('name'=>'is_wechats','title'=>'是否微信卡券','type'=>'radio','options'=>'is_wechats'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'id','title'=>'选取'),
		)),
		'search'=>array(
			'0'=>array('type'=>'radio','title'=>'卡券类型','name'=>'types','options'=>'types'),
			'1'=>array('type'=>'string','title'=>'卡券名称','name'=>'title'),
			'2'=>array('type'=>'radio','title'=>'是否微信卡券','name'=>'is_wechats','options'=>'is_wechats'),
		),
	);
	exi($return);
}
?>